<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="container-div">
         <div class="row">
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
		       
                <a class="btn btn-primary" onclick="$.operate.editTree()" shiro:hasPermission="system:area:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>
                <a class="btn btn-info" id="expandAllBtn">
                    <i class="fa fa-exchange"></i> 展开/折叠
                </a>
	        </div>
       		 <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-table" data-mobile-responsive="true"></table>
	        </div>
        </div>
	</div>
	
	<div th:include="include :: footer"></div>
	<script th:inline="javascript">
	
    	var addFlag = [[${@permission.hasPermi('module:area:add')}]];
        var editFlag = [[${@permission.hasPermi('module:area:edit')}]];
        var removeFlag = [[${@permission.hasPermi('module:area:remove')}]];
        var prefix = ctx + "module/area"

        $(function() {
            var options = {
                url: prefix + "/list",
                code: "areaCode",
		        parentCode: "parentCode",
		        uniqueId: "areaCode",
		        expandAll: false,
		        expandFirst: false,
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                
                modalName: "行政区划",
                columns: [{
                    field: 'selectItem', 
                    radio: true
                 },
 				{
 					field : 'areaCode', 
 		            align : 'center',
 					title : '区域编码' 
 				},
				{
					field : 'parentCode', 
		            align : 'center',
					title : '父区域编码' 
				},
				{
					field : 'treeLevel', 
		            align : 'center',
					title : '层次级别',
					visible : false
				},
				{
					field : 'treeNames', 
		            align : 'center',
					title : '全节点名' 
				},
				{
					field : 'areaName', 
		            align : 'center',
					title : '区域名称' 
				},				 
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:;" onclick="$.operate.edit(\'' + row.areaCode + '\')"><i class="fa fa-edit"></i>编辑</a> ');
		            	actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:;" onclick="$.operate.add(\'' + row.areaCode + '\')"><i class="fa fa-plus"></i>新增</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:;" onclick="$.operate.remove(\'' + row.areaCode + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.treeTable.init(options);
            
        });
    </script>
    
</body>
</html>